package com.gkzf.ai.module.crm.controller.app.product;

import com.gkzf.ai.framework.common.pojo.CommonResult;
import com.gkzf.ai.framework.datapermission.core.annotation.DataPermission;
import com.gkzf.ai.module.crm.controller.app.product.vo.ProductDetailsRespVO;
import com.gkzf.ai.module.crm.controller.app.product.vo.ProductPageReqVO;
import com.gkzf.ai.module.crm.controller.app.product.vo.ProductRespVO;
import com.gkzf.ai.module.crm.service.product.app.CrmProductAppService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import static com.gkzf.ai.framework.common.pojo.CommonResult.success;

@Tag(name = "App后台 - CRM 产品")
@RestController
@RequestMapping("/app/product")
@Validated
public class ProductController {

    @Resource
    private CrmProductAppService productService;


    @GetMapping("/get")
    @Operation(summary = "获得产品详情")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<ProductDetailsRespVO > getProduct(@RequestParam("id") Long id) {
        ProductDetailsRespVO product = productService.getAppProduct(id);
        return success(product);
    }


    @GetMapping("/page")
    @Operation(summary = "获得产品分页")
    @DataPermission
    public CommonResult<ProductRespVO> getProductPage(@Valid ProductPageReqVO pageVO) {
        ProductRespVO pageResult = productService.getAppProductPage(pageVO);
        return success(pageResult);
    }


}
